import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
  BreadcrumbItem: [],//面包屑
  LoadShowType: false,//loading动画弹出
  ActionInfo: { Account: '', list: [],AreaCode:'' },
}

const mutations = {
  updateBreadcrumb(state, msg) {//给面包屑增加值
    state.BreadcrumbItem = [];
    state.BreadcrumbItem.push(msg);
  },
  setActionList(state, msg) {
    state.ActionInfo.Account = msg.account;
    state.ActionInfo.AreaCode = msg.AreaCode;   
    for (var i = 0; i < msg.list.length; i++) {
      if (msg.list[i].CtrlUrl == msg.path) {
        state.ActionInfo.list.push(msg.list[i]);
      }
    }
  },
  desBreadcrumb(state, msg) {//清空面包屑
    state.BreadcrumbItem = [];
    state.BreadcrumbItem = [];
  },
  loadingShow(state) {//显示loading动画弹出
    state.LoadShowType = true;
  },
  loadingHide(state) {//隐藏loading动画弹出
    state.LoadShowType = false;
  }
}
const actions = {
  updateBreadcrumb: ({ commit }, BreadcrumbItem) => commit('updateBreadcrumb', BreadcrumbItem),//给面包屑增加值
  desBreadcrumb: ({ commit }) => commit('desBreadcrumb'),//清空面包屑
  loadingShow: ({ commit }) => commit('loadingShow'),//显示loading动画弹出
  loadingHide: ({ commit }) => commit('loadingHide'),//隐藏loading动画弹出
  setActionList: ({ commit }, ActionList) => commit('setActionList', ActionList)
}
export default new Vuex.Store({
  state,
  mutations,
  actions
})